feat(ramps-controller)!: source widened Headless Buy default redirect URL from RampsService - #9752
Merged
Merged
Conversation
saustrie-consensys
force-pushed
the
tram-3757-redirect-url
branch
from
August 1, 2026 17:45
25ecb5d to
92c3cd7
Compare
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Draft
10 tasks
saustrie-consensys
force-pushed
the
tram-3757-redirect-url
branch
from
August 3, 2026 15:14
ea0a8c2 to
a507c7f
Compare
… URL from environment
Move the widened-path default redirect ("fake callback") URL derivation into
the controller instead of accepting a client-injected URL callback.
- Add `getDefaultRedirectCallbackUrl(environment)` mapping each `RampsEnvironment`
to its `on-ramp-content` fake-callback host (dev uses `on-ramp.dev-api`, which
has no content deployment; local uses `localhost:3000`).
- Replace the `getDefaultRedirectUrl` callback option on `RampsControllerOptions`
with an `environment` option (defaults to Staging, matching `RampsService`);
the widened quote path derives the default from it.
BREAKING: `getDefaultRedirectUrl` is removed from `RampsControllerOptions`;
clients pass `environment` instead of injecting a URL callback. Behaviour is
preserved: an explicit caller `redirectUrl` still wins, and the native-only
(flag-off) path still injects nothing.
Make RampsControllerOptions.environment required so a production consumer cannot silently fall back to the Staging fake-callback after dropping getDefaultRedirectUrl. Document that the same environment must be used by RampsService and callback-matching UI.
…psService Make RampsService the single runtime owner of the Headless Buy fake-callback URL. RampsController asks for it through a new messenger action on the widened path when the caller omits redirectUrl, instead of taking a duplicated environment option or a client URL callback. - Export getDefaultRedirectCallbackUrl(environment) as the canonical map. - Expose RampsService:getDefaultRedirectCallbackUrl (sync; baseUrlOverride does not apply, because prod/staging callbacks use on-ramp-content hosts). - Remove getDefaultRedirectUrl and the temporary environment constructor option. - Pin the missing-delegation contract: undelegated hosts reject the whole getQuotes call, including MM Pay fiat quoting. BREAKING: hosts must delegate the new action (or spread RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS) and stop passing getDefaultRedirectUrl.
saustrie-consensys
force-pushed
the
tram-3757-redirect-url
branch
from
August 3, 2026 15:15
a507c7f to
366b2ae
Compare
saustrie-consensys
marked this pull request as ready for review
August 3, 2026 15:19
georgeweiler
approved these changes
Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
On the widened Headless Buy all-providers path, MetaMask Pay's quote request omits
redirectUrl. The quotes API only embeds abuyURL/buyWidgetwhen aredirectUrlis present, soRampsController.getQuotesmust supply a default there. Until now that default came from agetDefaultRedirectUrlcallback injected by the mobile client, which review flagged as an unusual controller-init pattern for a value core can derive itself.This PR moves ownership into core without giving
RampsControllera second copy of the environment:getDefaultRedirectCallbackUrl(environment)helper as the canonical environment-to-callback map (on-ramp-contentfor production/staging,on-ramp.dev-apifor development,localhost:3000for local).RampsService.getDefaultRedirectCallbackUrl()and the matching messenger action, which returns that URL for the environment the service was already constructed with.baseUrlOverridedeliberately does not apply: in production and staging the callback lives onon-ramp-content, not the API/on-ramp-cachehost thatbaseUrlOverridereplaces; using the API override here would break client completion matching.RampsEnvironment.Localyields a localhost callback pinned to port 3000.getDefaultRedirectUrlfromRampsControllerOptions. On the widened path, when the caller omitsredirectUrl, the controller callsRampsService:getDefaultRedirectCallbackUrl. Explicit callerredirectUrlstill wins; the native-only (flag-off) path still injects nothing.If a host upgrades without delegating the new action, the entire
RampsController:getQuotescall rejects (including MM Pay fiat quoting), rather than returning aggregator quotes without a widget URL. That is intentional and covered by a unit test.Breaking change
RampsService:getDefaultRedirectCallbackUrlto theRampsControllermessenger (prefer spreadingRAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONSinstead of extending a hand-written list), and drop anygetDefaultRedirectUrlconstructor argument.getRampCallbackBaseUrl()asgetDefaultRedirectCallbackUrl(getRampsEnvironment())in the same upgrade so quote defaults and Checkout completion detection share one environment source. Builds that setRAMPS_ENVIRONMENTdifferently fromMETAMASK_ENVIRONMENT(notably someexp/e2e-bsflavors) can otherwise mismatch.References
Checklist
Note
Medium Risk
Breaking messenger and constructor contract for Headless Buy / MM Pay quoting; mis-delegation fails the whole
getQuotescall, and env mismatch between service and UI callback detection could break checkout completion.Overview
Breaking: Widened Headless Buy quotes no longer use an injected
getDefaultRedirectUrlonRampsController. WhenmoneyHeadlessAllProvidersis on and the caller omitsredirectUrl, the controller callsRampsService:getDefaultRedirectCallbackUrland forwards that URL intogetQuotesso aggregator quotes get abuyURL/buyWidget. ExplicitredirectUrlstill wins; the native-only path does not call the service.Adds
getDefaultRedirectCallbackUrl(environment)(canonical env →/regions/fake-callbackmap, ignoringbaseUrlOverride) plusRampsService.getDefaultRedirectCallbackUrl()and the messenger action/type, exported from the package. Hosts must delegate the new action (listed inRAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS) orgetQuotesrejects; mobile should align UI callback matching with the same helper and environment source.Reviewed by Cursor Bugbot for commit 3b3ff32. Bugbot is set up for automated code reviews on this repo. Configure here.